// pages/familydoctor/servercenter/servercenter.js
var app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    update: false,
    collect: false,
    shanchanglist: ["全部(550)", "气胸(16)", "肺癌(18)", "胸腔积液(5)", "肋骨骨折(4)", "心包积液(2)", "多汗症(1)"],
    money: '',
    time_leng: '',
    addnum: '',
    url: '',
    key_words: '',
    id: ""
  },
  teamlist() {
    this.setData({
      update: !this.data.update
    })
  },
  two_even: function (e) {

    this.setData({
      allserve: true,
    })

  },
  askdoctor(e) {
    var that = this;
    let inquiry = e.currentTarget.dataset.num;
    var url = e.currentTarget.dataset.url
    var money = e.currentTarget.dataset.money
    var time_leng = e.currentTarget.dataset.time_leng
    var addnum = parseInt(e.currentTarget.dataset.ptzhuiw)
    var key_words = e.currentTarget.dataset.key_words;
    var selindex = e.currentTarget.dataset.index;
    console.log(selindex)
    that.setData({
      money: money,
      time_leng: time_leng,
      addnum: addnum,
      url: url,
      key_words: key_words,
      selindex: selindex
    })

  },
  team: function (e) {
    var url = this.data.url;
    var id = this.data.id;
    var money = this.data.money;
    var time_leng = this.data.time_leng;
    var addnum = this.data.addnum;
    var key_words = this.data.key_words;
    if (key_words == '') {
      wx.showModal({
        title: '提示',
        content: "请选择服务包类型",
      })
    } else {
      wx.navigateTo({
        url: '/hyb_yl/zhuanjiasubpages/pages/huanzhexinxi/huanzhexinxi?inquiry=&tid=' + id + '&money=' + money + '&time_leng=' + time_leng + '&addnum=' + addnum + '&key_words=' + key_words,
      })
    }
  },
  navicate() {
    var that = this
    wx.reLaunch({
      url: '/hyb_yl/tabBar/index/index',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var bgc = wx.getStorageSync('color')

    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })

    var that = this
    if (options.scene) {
      var info = decodeURIComponent(options.scene)
      var id = info;
      that.setData({
        id: id
      })
    } else {
      wx.setNavigationBarTitle({
        title: options.title,
      })
      var id = options.id
      that.setData({
        title: options.title,
        id: id
      })
    }

    that.getDetail();
    that.getPingjia();
  },
  // 获取详情
  getDetail: function () {
    var that = this;
    app.util.request({
      'url': "entry/wxapp/team.detail",
      data: {
        id: that.data.id,
        openid: wx.getStorageSync('openid')
      },
      success: function (res) {
        console.log(res)
        that.setData({
          info: res.data,
          collect: res.data.collect
        })
      }
    })
  },
  // 关注
  collect: function () {
    var that = this
    app.util.request({
      'url': 'entry/wxapp/team.changelove',
      data: {
        zid: that.data.id,
        openid: wx.getStorageSync('openid'),
        cerated_type: 6
      },
      success: function (res) {
        console.log(res)
      }
    })
    this.setData({
      collect: !this.data.collect
    })
    if (this.data.collect == true) {
      wx.showToast({
        title: '关注成功',
        icon: 'none',
      })
    } else {

      wx.showToast({
        title: '取消关注成功',
        icon: 'none',
      })
    }
  },
  // 获取评价
  getPingjia: function () {
    var that = this;
    app.util.request({
      'url': "entry/wxapp/team.getpingjia",
      data: {
        id: that.data.id
      },
      success: function (res) {
        that.setData({
          pingjia: res.data
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

})